home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / dev / obero / Interfaces3_6.lha / Interfaces / LowLevel.mod < prev    next >
Encoding:
Text File  |  1995-01-13  |  8.9 KB  |  289 lines

  1. (*
  2. (*  Amiga Oberon Interface Module:
  3. **  $VER: LowLevel.mod 40.15 (12.1.95) Oberon 3.6
  4. **
  5. **      (C) Copyright 1993 Commodore-Amiga, Inc.
  6. **          All Rights Reserved
  7. **
  8. **      (C) Copyright Oberon Interface 1993 by hartmut Goebel
  9. *)          All Rights Reserved
  10. *)
  11.  
  12. MODULE LowLevel;
  13.  
  14. IMPORT
  15.   e * := Exec,
  16.   Timer *,
  17.   u * := Utility,
  18.   SYSTEM;
  19.  
  20. CONST
  21.   lowlevelName * = "lowlevel.library";
  22.  
  23. TYPE
  24.   KeyQueryPtr * = UNTRACED POINTER TO KeyQuery;
  25.  
  26.  
  27. (*****************************************************************************)
  28.  
  29.  
  30. (* structure for use with QueryKeys() *)
  31.   KeyQuery * = STRUCT
  32.     keyCode * : INTEGER;
  33.     pressed * : e.BOOL;
  34.   END;
  35.  
  36.  
  37. (*****************************************************************************)
  38.  
  39. CONST
  40. (* bits in the return value of GetKey() *)
  41.   lShift     * = 16;
  42.   rShift     * = 17;
  43.   capsLock   * = 18;
  44.   control    * = 19;
  45.   lAlt       * = 20;
  46.   rAlt       * = 21;
  47.   lAmiga     * = 22;
  48.   rAmiga     * = 23;
  49.  
  50. (* bits in the return value of GetKey() for use with KeyDescription *)
  51.   kdLShift     * = 0;
  52.   kdRShift     * = 1;
  53.   kdCapsLock   * = 2;
  54.   kdControl    * = 3;
  55.   kdLAlt       * = 4;
  56.   kdRAlt       * = 5;
  57.   kdLAmiga     * = 6;
  58.   kdRAmiga     * = 7;
  59.  
  60. (*****************************************************************************)
  61.  
  62.  
  63. (* Tags for SetJoyPortAttrs() *)
  64.   sjaDummy            * = u.user+0C00100H;
  65.   sjaType             * = sjaDummy+1;      (* force type to mouse, joy, game cntrlr *)
  66.   sjaReinitialize     * = sjaDummy+2;      (* free potgo bits, reset to autosense   *)
  67.  
  68. (* Controller types for SJA_Type tag *)
  69.   sjyTypeAutosense    * = 0;
  70.   sjaTypeGameCtlr     * = 1;
  71.   sjaTypeMouse        * = 2;
  72.   sjaTypeJoystk       * = 3;
  73.  
  74.  
  75. (*****************************************************************************)
  76.  
  77.  
  78. (* ReadJoyPort() return value definitions *)
  79.  
  80. (* Port types *)
  81.   typeNotAvail * = ASH(00,28);     (* port data unavailable    *)
  82.   typeGameCtlr * = ASH(01,28);     (* port has game controller *)
  83.   typeMouse    * = ASH(02,28);     (* port has mouse           *)
  84.   typeJoystk   * = ASH(03,28);     (* port has joystick        *)
  85.   typeUnknown  * = ASH(04,28);     (* port has unknown device  *)
  86.   typeMask     * = ASH(15,28);     (* controller type          *)
  87.  
  88. (* Button types, valid for all types except JP_TYPE_NOTAVAIL *)
  89.   buttonBlue    * = 23;    (* Blue - Stop; Right Mouse                *)
  90.   buttonRed     * = 22;    (* Red - Select; Left Mouse; Joystick Fire *)
  91.   buttonYellow  * = 21;    (* Yellow - Repeat                         *)
  92.   buttonGreen   * = 20;    (* Green - Shuffle                         *)
  93.   buttonForward * = 19;    (* Charcoal - Forward                      *)
  94.   buttonReverse * = 18;    (* Charcoal - Reverse                      *)
  95.   buttonPlay    * = 17;    (* Grey - Play/Pause; Middle Mouse         *)
  96.   buttonMask    * = LONGSET{buttonBlue,buttonRed,buttonYellow,buttonGreen,
  97.                             buttonForward,buttonReverse,buttonPlay};
  98.  
  99. (* Direction types, valid for JP_TYPE_GAMECTLR and JP_TYPE_JOYSTK *)
  100.   joyUp         * = 3;
  101.   joyDown       * = 2;
  102.   joyLeft       * = 1;
  103.   joyRight      * = 0;
  104.   directionMask * = LONGSET{joyUp,joyDown,joyLeft,joyRight};
  105.  
  106. (* Mouse position reports, valid for JP_TYPE_MOUSE *)
  107.   mHorzMask * = ASH(255,0);           (* horizontal position *)
  108.   mVertMask * = ASH(255,8);           (* vertical position   *)
  109.   mouseMask * = mHorzMask + mVertMask;
  110.  
  111.  
  112. (*****************************************************************************)
  113.  
  114.  
  115. (* Tags for SystemControl() *)
  116.   sconDummy           * = u.user+00C00000H;
  117.   sconTakeoversys     * = sconDummy+0;
  118.   sconKillreq         * = sconDummy+1;
  119.   sconCdreboot        * = sconDummy+2;
  120.   sconStopinput       * = sconDummy+3;
  121.   sconAddcreatekeys   * = sconDummy+4;
  122.   sconRemcreatekeys   * = sconDummy+5;
  123.  
  124. (* Reboot control values for use with SCON_CDReboot tag *)
  125.   cdRebootOn          * = 1;
  126.   cdRebootOff         * = 0;
  127.   cdRebootDefault     * = 2;
  128.  
  129.  
  130. (*****************************************************************************)
  131.  
  132.  
  133. (* Rawkey codes returned when using SCON_AddCreateKeys with SystemControl() *)
  134.  
  135.   port0ButtonBlue    * = 072H;
  136.   port0ButtonRed     * = 078H;
  137.   port0ButtonYellow  * = 077H;
  138.   port0ButtonGreen   * = 076H;
  139.   port0ButtonForward * = 075H;
  140.   port0ButtonReverse * = 074H;
  141.   port0ButtonPlay    * = 073H;
  142.   port0JoyUp         * = 079H;
  143.   port0JoyDown       * = 07AH;
  144.   port0JoyLeft       * = 07CH;
  145.   port0JoyRight      * = 07BH;
  146.  
  147.   port1ButtonBlue    * = 0172H;
  148.   port1ButtonRed     * = 0178H;
  149.   port1ButtonYellow  * = 0177H;
  150.   port1ButtonGreen   * = 0176H;
  151.   port1ButtonForward * = 0175H;
  152.   port1ButtonReverse * = 0174H;
  153.   port1ButtonPlay    * = 0173H;
  154.   port1JoyUp         * = 0179H;
  155.   port1JoyDown       * = 017AH;
  156.   port1JoyLeft       * = 017CH;
  157.   port1JoyRight      * = 017BH;
  158.  
  159.   port2ButtonBlue    * = 0272H;
  160.   port2ButtonRed     * = 0278H;
  161.   port2ButtonYellow  * = 0277H;
  162.   port2ButtonGreen   * = 0276H;
  163.   port2ButtonForward * = 0275H;
  164.   port2ButtonReverse * = 0274H;
  165.   port2ButtonPlay    * = 0273H;
  166.   port2JoyUp         * = 0279H;
  167.   port2JoyDown       * = 027AH;
  168.   port2JoyLeft       * = 027CH;
  169.   port2JoyRight      * = 027BH;
  170.  
  171.   port3ButtonBlue    * = 0372H;
  172.   port3ButtonRed     * = 0378H;
  173.   port3ButtonYellow  * = 0377H;
  174.   port3ButtonGreen   * = 0376H;
  175.   port3ButtonForward * = 0375H;
  176.   port3ButtonReverse * = 0374H;
  177.   port3ButtonPlay    * = 0373H;
  178.   port3JoyUp         * = 0379H;
  179.   port3JoyDown       * = 037AH;
  180.   port3JoyLeft       * = 037CH;
  181.   port3JoyRight      * = 037BH;
  182.  
  183.  
  184. (*****************************************************************************)
  185.  
  186.  
  187. (* Return values for GetLanguageSelection() *)
  188.   langUnknown     * = 0;
  189.   american        * = 1;           (* American English *)
  190.   english         * = 2;           (* British English  *)
  191.   german          * = 3;
  192.   french          * = 4;
  193.   spanish         * = 5;
  194.   italian         * = 6;
  195.   portuguese      * = 7;
  196.   danish          * = 8;
  197.   dutch           * = 9;
  198.   norwegian       * = 10;
  199.   finnish         * = 11;
  200.   swedish         * = 12;
  201.   japanese        * = 13;
  202.   chinese         * = 14;
  203.   arabic          * = 15;
  204.   greek           * = 16;
  205.   hebrew          * = 17;
  206.   korean          * = 18;
  207.  
  208. (*****************************************************************************)
  209.  
  210. TYPE
  211.   (* some dummys for type security *)
  212.   KBIntHandle     * = UNTRACED POINTER TO STRUCT END;
  213.   TimerIntHandle  * = UNTRACED POINTER TO STRUCT END;
  214.   VBlankIntHandle * = UNTRACED POINTER TO STRUCT END;
  215.  
  216.   (* easy handling of GetKey() result *)
  217.   KeyDescription * = STRUCT
  218.     qualifier *: SET;
  219.     code      *: INTEGER;
  220.   END;
  221.  
  222.  
  223. (* $StackChk- $RangeChk- $NilChk- $OvflChk- $ReturnChk- $CaseChk- *)
  224.  
  225. VAR
  226.   base *: e.LibraryPtr;
  227.  
  228. (*--- functions in V40 or higher (Release 3.1) ---*)
  229.  
  230. (* CONTROLLER HANDLING *)
  231.  
  232. PROCEDURE ReadJoyPort    *{base,-001EH}(port{0}       : LONGINT): LONGSET;
  233.  
  234. (* LANGUAGE HANDLING *)
  235.  
  236. PROCEDURE GetLanguageSelection *{base,-0024H}()       : SHORTINT;
  237.  
  238. (* KEYBOARD HANDLING *)
  239.  
  240. PROCEDURE GetKey         *{base,-0030H}()             : KeyDescription;
  241. PROCEDURE QueryKeys      *{base,-0036H}(queryArray{8} : KeyQueryPtr;
  242.                                         arraySize{1}  : LONGINT);
  243. PROCEDURE AddKBInt       *{base,-003CH}(intRoutine{8} : e.PROC;
  244.                                         intData{9}    : e.APTR): KBIntHandle;
  245. PROCEDURE RemKBInt       *{base,-0042H}(intHandle{9}  : KBIntHandle);
  246.  
  247. (* SYSTEM HANDLING *)
  248.  
  249. PROCEDURE SystemControlA *{base,-0048H}(tagList{9}    : ARRAY OF u.TagItem): u.TagID;
  250. PROCEDURE SystemControl  *{base,-0048H}(firstTag{9}.. : u.Tag): u.TagID;
  251.  
  252. (* TIMER HANDLING *)
  253.  
  254. PROCEDURE AddTimerInt    *{base,-004EH}(intRoutine{8} : e.PROC;
  255.                                         intData{9}    : e.APTR): TimerIntHandle;
  256. PROCEDURE RemTimerInt    *{base,-0054H}(intHandle{9}  : TimerIntHandle);
  257. PROCEDURE StopTimerInt   *{base,-005AH}(intHandle{9}  : TimerIntHandle);
  258. PROCEDURE StartTimerInt  *{base,-0060H}(intHandle{9}  : TimerIntHandle;
  259.                                         timeInterval{0}: LONGINT;
  260.                                         continuous{1} : e.LONGBOOL);
  261. PROCEDURE ElapsedTime    *{base,-0066H}(VAR context{8}: Timer.EClockVal): LONGINT;
  262.  
  263. (* VBLANK HANDLING *)
  264.  
  265. PROCEDURE AddVBlankInt   *{base,-006CH}(intRoutine{8} : e.PROC;
  266.                                         intData{9}    : e.APTR): VBlankIntHandle;
  267. PROCEDURE RemVBlankInt   *{base,-0072H}(intHandle{9}  : VBlankIntHandle);
  268.  
  269. (* MORE CONTROLLER HANDLING *)
  270.  
  271. PROCEDURE SetJoyPortAttrsA *{base,-0084H}(portNumber{0}: LONGINT;
  272.                                          tagList{9}   : ARRAY OF u.TagItem): BOOLEAN;
  273. PROCEDURE SetJoyPortAttrs *{base,-0084H}(portNumber{0}: LONGINT;
  274.                                          firstTag{9}..: u.Tag): BOOLEAN;
  275.  
  276.  
  277. (* only a dummy to make sure SIZE(KeyDescriptor) = SIZE(LONGINT) *)
  278. PROCEDURE CheckKeyDescriptorSize(kd: KeyDescription): LONGINT;
  279. BEGIN RETURN SYSTEM.VAL(LONGINT,kd); END CheckKeyDescriptorSize;
  280.  
  281. BEGIN
  282.   base := e.OpenLibrary(lowlevelName,40);
  283.  
  284. CLOSE
  285.   IF base # NIL THEN e.CloseLibrary(base); END;
  286.  
  287. END LowLevel.
  288.  
  289.